package com.sunyard.manage;

import com.sunyard.utils.IpUtils;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@SpringBootApplication(scanBasePackages = {"com.sunyard.manage", "com.sunyard.aop", "com.sunyard.dal.aop",
        "com.sunyard.config", "com.sunyard.redisUtil", "com.sunyard.manage.controller"})
@RestController
@EnableDiscoveryClient
@EnableFeignClients
@EnableAsync
@MapperScan(value = "com.sunyard.dal.mapper")
public class ManageApplication {

    @Autowired
    private DiscoveryClient discoveryClient;

    /**
     * 获取所有服务
     */
    @RequestMapping("/services")
    public Object services() {
        return discoveryClient.getServices();
    }

    @RequestMapping("/home")
    public String home() {
        return "manage,Hello World,ip=" + IpUtils.getLocalIp();
    }

    public static void main(String[] args) throws IOException {
        SpringApplication.run(ManageApplication.class, args);
    }

}
